export default function controlColBoxDialog(state, { that }) {
  let colBox = JSON.parse(JSON.stringify(state.componentList["colBox"]));
  that.colBoxDialog = false;

  colBox.attrs.class = `colBox${new Date().getTime()}`;
  that.colBoxWidth.forEach((item, index) => {
    colBox.children.push({
      attrs: {
        class: "colBoxItem" + index,
        "data-type": "colBoxItem",
      },
      style: {
        padding: "10px 10px 10px 10px",
        width: item + "%",
      },
      children: [],
      tagName: "div",
    });
  });

  state.domStackNum += 1;
  state.domStack.splice(state.domStackNum);
  state.domStack.push({
    type: "add",
    pageName: that.pageName,
    data: [colBox, state.page.tree[that.pageName].length],
    path: [
      {
        className: colBox.attrs.class,
      },
    ],
  });

  state.page.tree[that.pageName].push(colBox);
}
